<template>
  <div class="patrol">
    <div style="padding: 10px 0">
      <i class="el-icon-back back" @click="$router.go(-1)"></i>
    </div>
    <el-form
      class="patrol_form"
      ref="patrolForm"
      :model="form"
      :rules="rules"
      :label-width="labelWidth"
    >
      <el-form-item label="巡检责任人:" label-width="100px" prop="name">
        <el-input
          style="width: 220px"
          v-model="form.name"
          placeholder="请输入巡检人"
          clearable
          :disabled="$route.query.oper === '1' ? true : false"
        ></el-input>
      </el-form-item>
      <el-form-item label="巡检日期:" label-width="100px" prop="date">
        <el-date-picker
          v-model="form.date"
          value-format="yyyy-MM-dd"
          type="date"
          :picker-options="pickerOptions"
          placeholder="请选择巡检日期"
          :disabled="$route.query.oper === '1' ? true : false"
        >
        </el-date-picker>
      </el-form-item>
      <!-- <el-button type="primary" @click="deviceAdd">增加机房</el-button> -->
      <div class="patrol_form_content">
        <el-menu
          default-active="CityPatrol"
          class="patrol_menu"
          @select="handleSelect"
        >
          <el-submenu index="1">
            <template slot="title">
              <span>机房远程巡检</span>
            </template>
            <el-menu-item index="CityPatrol">市局机房动环系统巡检</el-menu-item>
            <el-menu-item index="PolicePatrol"
              >交警机房动环系统巡检</el-menu-item
            >
            <el-menu-item index="IntelligencePatrol"
              >数智慧运维系统</el-menu-item
            >
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <span>机房现场巡检</span>
            </template>
            <el-menu-item index="SwitchRoom">配电房</el-menu-item>
            <el-menu-item index="UPSRoom">UPS机房</el-menu-item>
            <el-menu-item index="BusinessRoom">业务机房</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <span>品高云巡检</span>
            </template>
            <el-menu-item index="GACloud">GA网品高云</el-menu-item>
            <el-menu-item index="VideoCloud">视频专网品高云</el-menu-item>
            <el-menu-item index="SecondClassCloud">二类网品高云</el-menu-item>
            <el-menu-item index="SocietyCloud">社会资源网品高云</el-menu-item>
            <el-menu-item index="NeworkCloud">互联网品高云</el-menu-item>
            <el-menu-item index="CompanyCloud">企事业网品高云</el-menu-item>
            <el-menu-item index="FrontCloud">边界前置区品高云</el-menu-item>
            <el-menu-item index="EndCloud">边界后置区品高云</el-menu-item>
            <el-menu-item index="DataFrontCloud"
              >数据域前置区品高云</el-menu-item
            >
          </el-submenu>
        </el-menu>
        <div class="content_right">
          <!-- <div class="save">
            <el-button type="primary" @click="submitSingleForm()"
              >保存</el-button
            >
          </div> -->
          <!-- <keep-alive>
            <component :is="currentCom"></component>
          </keep-alive> -->
          <city-patrol
            v-show="currentCom === 'CityPatrol'"
            :list="getRoomData(1)"
          ></city-patrol>
          <police-patrol
            v-show="currentCom === 'PolicePatrol'"
            :list="getRoomData(2)"
          ></police-patrol>
          <intelligence-patrol
            v-show="currentCom === 'IntelligencePatrol'"
            :list="getRoomData(3)"
          ></intelligence-patrol>
          <switch-room
            v-show="currentCom === 'SwitchRoom'"
            :list="getRoomData(4)"
          ></switch-room>
          <uPS-room
            v-show="currentCom === 'UPSRoom'"
            :list="getRoomData(5)"
          ></uPS-room>
          <business-room
            v-show="currentCom === 'BusinessRoom'"
            :list="getRoomData(6)"
          ></business-room>
          <gA-cloud
            v-show="currentCom === 'GACloud'"
            :list="getRoomData(7)"
          ></gA-cloud>
          <video-cloud
            v-show="currentCom === 'VideoCloud'"
            :list="getRoomData(8)"
          ></video-cloud>
          <second-class-cloud
            v-show="currentCom === 'SecondClassCloud'"
            :list="getRoomData(9)"
          ></second-class-cloud>
          <society-cloud
            v-show="currentCom === 'SocietyCloud'"
            :list="getRoomData(10)"
          ></society-cloud>
          <nework-cloud
            v-show="currentCom === 'NeworkCloud'"
            :list="getRoomData(11)"
          ></nework-cloud>
          <company-cloud
            v-show="currentCom === 'CompanyCloud'"
            :list="getRoomData(12)"
          ></company-cloud>
          <front-cloud
            v-show="currentCom === 'FrontCloud'"
            :list="getRoomData(13)"
          ></front-cloud>
          <end-cloud
            v-show="currentCom === 'EndCloud'"
            :list="getRoomData(14)"
          ></end-cloud>
          <data-front-cloud
            v-show="currentCom === 'DataFrontCloud'"
            :list="getRoomData(15)"
          ></data-front-cloud>
        </div>
      </div>
      <div style="padding-top: 10px" class="save">
        <el-button type="primary" @click="submitForm()">保存</el-button>
      </div>
    </el-form>
  </div>
</template>

<script>
import CityPatrol from '@/components/long-range/CityPatrol.vue';
import PolicePatrol from '@/components/long-range/PolicePatrol.vue';
import IntelligencePatrol from '@/components/long-range/IntelligencePatrol.vue';
import SwitchRoom from '@/components/locale/SwitchRoom.vue';
import UPSRoom from '@/components/locale/UPSRoom.vue';
import BusinessRoom from '@/components/locale/BusinessRoom.vue';
import GACloud from '@/components/pinyun-cloud/GACloud.vue';
import VideoCloud from '@/components/pinyun-cloud/VideoCloud.vue';
import SecondClassCloud from '@/components/pinyun-cloud/SecondClassCloud.vue';
import SocietyCloud from '@/components/pinyun-cloud/SocietyCloud.vue';
import NeworkCloud from '@/components/pinyun-cloud/NeworkCloud.vue';
import CompanyCloud from '@/components/pinyun-cloud/CompanyCloud.vue';
import FrontCloud from '@/components/pinyun-cloud/FrontCloud.vue';
import EndCloud from '@/components/pinyun-cloud/EndCloud.vue';
import DataFrontCloud from '@/components/pinyun-cloud/DataFrontCloud.vue';
import {
  addRoom,
  editRoom,
  addDevice,
  saveInspection,
  addInspection,
  getInspectionForm,
  editInspection,
} from '@/api/index';
export default {
  name: 'HomeView',
  components: {
    CityPatrol,
    PolicePatrol,
    IntelligencePatrol,
    SwitchRoom,
    UPSRoom,
    BusinessRoom,
    GACloud,
    VideoCloud,
    SecondClassCloud,
    SocietyCloud,
    NeworkCloud,
    CompanyCloud,
    FrontCloud,
    EndCloud,
    DataFrontCloud,
  },
  data() {
    return {
      form: {
        name: '',
        date: '',
      },
      rules: {
        name: [{ required: true, message: '请输入巡检人', trigger: 'blur' }],
        date: [
          { required: true, message: '请选择巡检日期', trigger: 'change' },
        ],
      },
      currentCom: 'CityPatrol',
      labelWidth: '350px',
      formList: [],
      pickerOptions: {
        disabledDate: (date) => {
          // 在这里编写自定义的日期禁用逻辑
          // 返回true表示禁用该日期，返回false表示启用该日期
          // 例如，禁用所有今天之前的日期：
          return date > new Date();
        },
      },
    };
  },
  mounted() {
    if (this.$route.query.oper === '1') {
      this.form.name = this.$route.query.inspector;
      this.form.date = this.$route.query.inspection_date;
      this.getForm();
    }
    // this.roomAdd();
    // this.deviceAdd();
  },
  computed: {
    inspectionList() {
      return this.$store.state.inspectionList;
    },
  },
  methods: {
    getRoomData(id) {
      return this.formList.filter((item) => item.room_id === id);
    },
    async getForm() {
      const res = await getInspectionForm({
        id: this.$route.query.inspection_id,
      });
      this.formList = res || [];
    },
    async submitForm() {
      //新增
      if (this.$route.query.oper === '0') {
        this.$refs.patrolForm.validate(async (valid) => {
          if (valid) {
            const res = await addInspection({
              inspector: this.form.name,
              inspection_time: this.form.date,
            });
            this.inspectionList.flat().map((item) => {
              item.inspector = this.form.name;
              item.inspection_time = this.form.date;
              item.inspection_id = res.inspection_id;
            });
            await saveInspection({
              inspector: this.form.name,
              inspection_time: this.form.date,
              inspections: this.inspectionList.flat(),
            });
            this.$message.success('保存成功');
            // this.$router.go(-1);
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      } else {
        //编辑
        await editInspection({
          inspection_id: this.$route.query.inspection_id,
          inspections: this.inspectionList.flat(),
        });
        this.$message.success('修改成功');
      }
    },
    async submitSingleForm() {
      const objMap = {
        CityPatrol: 0,
        PolicePatrol: 1,
        IntelligencePatrol: 2,
        SwitchRoom: 3,
        UPSRoom: 4,
        BusinessRoom: 5,
        GACloud: 6,
        VideoCloud: 7,
        SecondClassCloud: 8,
        SocietyCloud: 9,
        NeworkCloud: 10,
        CompanyCloud: 11,
        FrontCloud: 12,
        EndCloud: 13,
        DataFrontCloud: 14,
      };
      this.inspectionList.flat().map((item) => {
        item.inspector = this.form.name;
        item.inspection_time = this.form.date;
      });
      await saveInspection({
        inspections: this.inspectionList[objMap[this.currentCom]],
      });
    },
    handleSelect(e) {
      this.currentCom = e;
    },
    async roomAdd() {
      const params = [
        {
          room_name: '市局机房动环系统',
          created_by: 'admin',
          updated_by: '',
          pid: '1',
        },
        {
          room_name: '交警机房动环系统巡检',
          created_by: 'admin',
          updated_by: '',
          pid: '1',
        },
        {
          room_name: '数智慧运维系统',
          created_by: 'admin',
          updated_by: '',
          pid: '1',
        },
        {
          room_name: '配电房',
          created_by: 'admin',
          updated_by: '',
          pid: '2',
        },
        {
          room_name: 'UPS机房',
          created_by: 'admin',
          updated_by: '',
          pid: '2',
        },
        {
          room_name: '业务机房',
          created_by: 'admin',
          updated_by: '',
          pid: '2',
        },
        {
          room_name: 'GA网品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '视频专网品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '二类网品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '社会资源网品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '互联网品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '企事业网品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '边界前置区品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '边界后置区品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
        {
          room_name: '数据域前置区品高云',
          created_by: 'admin',
          updated_by: '',
          pid: '3',
        },
      ];
      params.map(async (item) => {
        await addRoom(item);
      });
    },
    async roomEdit() {
      const params = {
        room_id: 2,
        room_name: '测试',
        created_by: 'admin1',
        updated_by: '2',
      };
      await editRoom(params);
    },
    async deviceAdd() {
      const list = [
        { room_id: 1, name: '配电柜状态' },
        { room_id: 1, name: 'UPS状态' },
        { room_id: 1, name: '空调状态' },
        { room_id: 1, name: '漏水状态' },
        { room_id: 1, name: '温湿度状态' },
        { room_id: 1, name: '消防状态' },

        { room_id: 2, name: '配电柜状态' },
        { room_id: 2, name: 'UPS状态' },
        { room_id: 2, name: '空调状态' },
        { room_id: 2, name: '漏水状态' },
        { room_id: 2, name: '温湿度状态' },
        { room_id: 2, name: '消防状态' },

        { room_id: 3, name: '网络设备运行情况' },
        { room_id: 3, name: '网络设备告警情况' },
        { room_id: 3, name: '服务器设备运行情况' },
        { room_id: 3, name: '服务器设备告警情况' },
        { room_id: 4, name: '配电开关柜状态' },
        { room_id: 4, name: '配电开关柜开关状态' },
        { room_id: 4, name: '配电柜电线状态' },
        { room_id: 4, name: '空调运行状态' },
        { room_id: 4, name: '空调告警状态' },
        { room_id: 4, name: '空调排水状态' },
        { room_id: 4, name: '消防监控点位状态' },
        { room_id: 4, name: '消防器材状态' },

        { room_id: 5, name: '电源输入柜状态' },
        { room_id: 5, name: 'UPS主机运行状态' },
        { room_id: 5, name: 'UPS主机告警状态' },
        { room_id: 5, name: '电池温度状态' },
        { room_id: 5, name: '电池无变形状态' },
        { room_id: 5, name: '电池无漏液状态' },
        { room_id: 5, name: '空调运行状态' },
        { room_id: 5, name: '空调告警状态' },
        { room_id: 5, name: '空调排水状态' },
        { room_id: 5, name: '消防主机运行状态' },
        { room_id: 5, name: '消防监控点位状态' },
        { room_id: 5, name: '消防器材状态' },

        { room_id: 6, name: '环境和地面干净' },
        { room_id: 6, name: '无堆放杂物' },
        { room_id: 6, name: '机柜设备规范整齐' },
        { room_id: 6, name: '机柜线路整齐' },
        { room_id: 6, name: '机房各区域温湿度状态' },
        { room_id: 6, name: '设备指示灯状态' },
        { room_id: 6, name: '空调运行状态' },
        { room_id: 6, name: '空调告警状态' },
        { room_id: 6, name: '空调排水状态' },
        { room_id: 6, name: '消防主机运行状态' },
        { room_id: 6, name: '消防监控点位状态' },
        { room_id: 6, name: '消防器材状态' },

        { room_id: 7, name: '登录页面状态' },
        { room_id: 7, name: '登录口令状态' },
        { room_id: 7, name: '平台消息记录信息状态' },
        { room_id: 7, name: '登录告警状态无异常' },
        { room_id: 7, name: '监控top-主机CPU使用率状态' },
        { room_id: 7, name: '监控top-主机内存使用状态' },
        { room_id: 7, name: '监控top-主机磁盘使用状态' },
        { room_id: 7, name: '服务器状态监控状态' },
        { room_id: 7, name: '所有节点状态' },
        { room_id: 7, name: '市局第一套存储集群状态' },
        { room_id: 7, name: '市局第一套存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '市局第一套存储集群monitor状态' },
        { room_id: 7, name: '市局第一套存储集群osd状态' },
        { room_id: 7, name: '国产化X86市局存储集群状态' },
        { room_id: 7, name: '国产化X86市局存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '国产化X86市局存储集群monitor状态' },
        { room_id: 7, name: '国产化X86市局存储集群osd状态' },
        { room_id: 7, name: '国产化arm交警存储集群状态' },
        { room_id: 7, name: '国产化arm交警存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '国产化arm交警存储集群monitor状态' },
        { room_id: 7, name: '国产化arm交警存储集群osd状态' },
        { room_id: 7, name: '云盘存储集群状态' },
        { room_id: 7, name: '云盘存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '云盘存储集群monitor状态' },
        { room_id: 7, name: '云盘存储集群osd状态' },
        { room_id: 7, name: '市局第二套高性能存储集群状态' },
        { room_id: 7, name: '市局第二套高性能存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '市局第二套高性能存储集群monitor状态' },
        { room_id: 7, name: '市局第二套高性能存储集群osd状态' },
        { room_id: 7, name: '市局第四套存储集群状态' },
        { room_id: 7, name: '市局第四套存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '市局第四套存储集群monitor状态' },
        { room_id: 7, name: '市局第四套存储集群osd状态' },
        { room_id: 7, name: '市局第三套存储集群状态' },
        { room_id: 7, name: '市局第三套存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '市局第三套存储集群monitor状态:' },
        { room_id: 7, name: '市局第三套存储集群osd状态' },
        { room_id: 7, name: '国产化arm市局存储集群状态' },
        { room_id: 7, name: '国产化arm市局存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '国产化arm市局存储集群monitor状态' },
        { room_id: 7, name: '国产化arm市局存储集群osd状态' },
        { room_id: 7, name: '交警存储集群状态' },
        { room_id: 7, name: '交警存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '交警存储集群monitor状态' },
        { room_id: 7, name: '交警存储集群osd状态' },
        { room_id: 7, name: '交警高性能存储集群状态' },
        { room_id: 7, name: '交警高性能存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '交警高性能存储集群monitor状态' },
        { room_id: 7, name: '交警高性能存储集群osd状态' },
        { room_id: 7, name: '雪亮工程存储集群状态' },
        { room_id: 7, name: '雪亮工程存储集群存储容量使用率小于70％' },
        { room_id: 7, name: '雪亮工程存储集群monitor状态' },
        { room_id: 7, name: '雪亮工程存储集群osd状态' },

        { room_id: 8, name: '登录页面状态' },
        { room_id: 8, name: '登录口令状态' },
        { room_id: 8, name: '平台消息记录信息状态' },
        { room_id: 8, name: '登录告警状态无异常' },
        { room_id: 8, name: '监控top-主机CPU使用率状态' },
        { room_id: 8, name: '监控top-主机内存使用状态' },
        { room_id: 8, name: '监控top-主机磁盘使用状态' },
        { room_id: 8, name: '服务器状态监控状态' },
        { room_id: 8, name: '所有节点状态' },
        { room_id: 8, name: '市局第一套存储集群状态' },
        { room_id: 8, name: '市局第一套存储集群存储容量使用率小于70％' },
        { room_id: 8, name: '市局第一套存储集群monitor状态' },
        { room_id: 8, name: '市局第一套存储集群osd状态' },
        { room_id: 8, name: '雪亮工程存储集群状态' },
        { room_id: 8, name: '雪亮工程存储集群存储容量使用率小于70％' },
        { room_id: 8, name: '雪亮工程存储集群monitor状态' },
        { room_id: 8, name: '雪亮工程存储集群osd状态' },

        { room_id: 9, name: '登录页面状态' },
        { room_id: 9, name: '登录口令状态' },
        { room_id: 9, name: '平台消息记录信息状态' },
        { room_id: 9, name: '登录告警状态无异常' },
        { room_id: 9, name: '监控top-主机CPU使用率状态' },
        { room_id: 9, name: '监控top-主机内存使用状态' },
        { room_id: 9, name: '监控top-主机磁盘使用状态' },
        { room_id: 9, name: '服务器状态监控状态' },
        { room_id: 9, name: '所有节点状态' },
        { room_id: 9, name: '存储集群状态' },
        { room_id: 9, name: '存储集群存储容量使用率小于70％' },
        { room_id: 9, name: '存储集群monitor状态' },
        { room_id: 9, name: '存储集群osd状态' },

        { room_id: 10, name: '登录页面状态' },
        { room_id: 10, name: '登录口令状态' },
        { room_id: 10, name: '平台消息记录信息状态' },
        { room_id: 10, name: '登录告警状态无异常' },
        { room_id: 10, name: '监控top-主机CPU使用率状态' },
        { room_id: 10, name: '监控top-主机内存使用状态' },
        { room_id: 10, name: '监控top-主机磁盘使用状态' },
        { room_id: 10, name: '服务器状态监控状态' },
        { room_id: 10, name: '所有节点状态' },
        { room_id: 10, name: '存储集群状态' },
        { room_id: 10, name: '存储集群存储容量使用率小于70％' },
        { room_id: 10, name: '存储集群monitor状态' },
        { room_id: 10, name: '存储集群osd状态' },

        { room_id: 11, name: '登录页面状态' },
        { room_id: 11, name: '登录口令状态' },
        { room_id: 11, name: '平台消息记录信息状态' },
        { room_id: 11, name: '登录告警状态无异常' },
        { room_id: 11, name: '监控top-主机CPU使用率状态' },
        { room_id: 11, name: '监控top-主机内存使用状态' },
        { room_id: 11, name: '监控top-主机磁盘使用状态' },
        { room_id: 11, name: '服务器状态监控状态' },
        { room_id: 11, name: '所有节点状态' },
        { room_id: 11, name: '存储集群状态' },
        { room_id: 11, name: '存储集群存储容量使用率小于70％' },
        { room_id: 11, name: '存储集群monitor状态' },
        { room_id: 11, name: '存储集群osd状态' },

        { room_id: 12, name: '登录页面状态' },
        { room_id: 12, name: '登录口令状态' },
        { room_id: 12, name: '平台消息记录信息状态' },
        { room_id: 12, name: '登录告警状态无异常' },
        { room_id: 12, name: '监控top-主机CPU使用率状态' },
        { room_id: 12, name: '监控top-主机内存使用状态' },
        { room_id: 12, name: '监控top-主机磁盘使用状态' },
        { room_id: 12, name: '服务器状态监控状态' },
        { room_id: 12, name: '所有节点状态' },
        { room_id: 12, name: '存储集群状态' },
        { room_id: 12, name: '存储集群存储容量使用率小于70％' },
        { room_id: 12, name: '存储集群monitor状态' },
        { room_id: 12, name: '存储集群osd状态' },

        { room_id: 13, name: '登录页面状态' },
        { room_id: 13, name: '登录口令状态' },
        { room_id: 13, name: '平台消息记录信息状态' },
        { room_id: 13, name: '登录告警状态无异常' },
        { room_id: 13, name: '监控top-主机CPU使用率状态' },
        { room_id: 13, name: '监控top-主机内存使用状态' },
        { room_id: 13, name: '监控top-主机磁盘使用状态' },
        { room_id: 13, name: '服务器状态监控状态' },
        { room_id: 13, name: '所有节点状态' },
        { room_id: 13, name: '存储集群状态' },
        { room_id: 13, name: '存储集群存储容量使用率小于70％' },
        { room_id: 13, name: '存储集群monitor状态' },
        { room_id: 13, name: '存储集群osd状态' },

        { room_id: 14, name: '登录页面状态' },
        { room_id: 14, name: '登录口令状态' },
        { room_id: 14, name: '平台消息记录信息状态' },
        { room_id: 14, name: '登录告警状态无异常' },
        { room_id: 14, name: '监控top-主机CPU使用率状态' },
        { room_id: 14, name: '监控top-主机内存使用状态' },
        { room_id: 14, name: '监控top-主机磁盘使用状态' },
        { room_id: 14, name: '服务器状态监控状态' },
        { room_id: 14, name: '所有节点状态' },
        { room_id: 14, name: '存储集群状态' },
        { room_id: 14, name: '存储集群存储容量使用率小于70％' },
        { room_id: 14, name: '存储集群monitor状态' },
        { room_id: 14, name: '存储集群osd状态' },

        { room_id: 15, name: '登录页面状态' },
        { room_id: 15, name: '登录口令状态' },
        { room_id: 15, name: '平台消息记录信息状态' },
        { room_id: 15, name: '登录告警状态无异常' },
        { room_id: 15, name: '监控top-主机CPU使用率状态' },
        { room_id: 15, name: '监控top-主机内存使用状态' },
        { room_id: 15, name: '监控top-主机磁盘使用状态' },
        { room_id: 15, name: '服务器状态监控状态' },
        { room_id: 15, name: '所有节点状态' },
        { room_id: 15, name: '存储集群状态' },
        { room_id: 15, name: '存储集群存储容量使用率小于70％' },
        { room_id: 15, name: '存储集群monitor状态' },
        { room_id: 15, name: '存储集群osd状态' },
      ];
      list.map(async (item) => {
        const params = {
          room_id: item.room_id,
          name: item.name,
          status: 1,
          created_by: 'admin',
          updated_by: '',
          factory_name: '某某厂家',
          telephone: '12345678911',
          remark: '',
        };
        if (item.room_id === 15) {
          await addDevice(params);
        }
      });
    },
  },
};
</script>

<style scoped lang="scss">
.patrol {
  width: 1100px;
  height: 100%;
  padding: 20px 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  .back {
    font-size: 30px;
    color: #aaa;
    border: 1px solid #aaa;
    border-radius: 50%;
    cursor: pointer;
  }
  .patrol_menu {
    width: 220px;
    overflow: auto;
  }
  .patrol_form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    .patrol_form_content {
      flex: 1;
      overflow: hidden;
      display: flex;
      border: 1px solid #eee;
      border-radius: 8px;
      .content_right {
        flex: 1;
        height: 100%;
        padding: 10px;
        overflow: auto;
      }
      .small_title {
        margin-bottom: 10px;
      }
      .sub_title {
        margin-bottom: 22px;
      }
    }
    .save {
      display: flex;
      justify-content: flex-end;
    }
  }
}
</style>
